package cloud.tianai.ram.policy.demo;

import cloud.tianai.ram.policy.common.handler.PermissionHandler;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cloud.tianai.ram.policy.client.ActionHolder;
import cloud.tianai.ram.policy.client.annotation.Action;

import java.util.Collection;

@Action(value ="zb:", action = "11", description = "招标项目:")
@RestController
public class DemoController {

    @Autowired
    private PermissionHandler permissionHandler;
    @Autowired
    private ActionHolder actionHolder;
    @GetMapping("/test/{id}")
    @Action(resource = "zhuanjiaku:zhuanjiachouqu:{#id}", action = "put", description ="专家抽取:详情")
    public String test(@PathVariable String id) {
        return "success";
    }

    @PostMapping("/test2/{aa}")
    @Action(resource = "qiyeguanli:qiyexingxi:{#aa}:{#d.id}", action = "put", hitThrowError = false, description ="企业管理:企业信息:详情")
    public String test2(@PathVariable String aa, @RequestBody Body d) {
        return "success2";
    }

    @GetMapping("/get")
    public Collection<cloud.tianai.ram.policy.common.model.dto.Action> test3() {
        return actionHolder.actionList();
    }


    @Data
    public static class Body {
        private String id;
        private String name;
    }
}
